package net;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class Client {
	public static void main(String[] args) throws Exception{
		test();
	}

	private static void test() throws Exception{
		Socket s = new Socket("172.16.1.230",21);
		InputStream in = s.getInputStream();
		BufferedReader bin = new BufferedReader(new InputStreamReader(in));
		final PrintWriter out = new PrintWriter(new OutputStreamWriter(s
				.getOutputStream()));
		new Thread(){
			public void run() {
				while(true){
//					String line = JOptionPane.showInputDialog("");
					Scanner in = new Scanner(System.in);
					String line = in.nextLine();
					out.println(line);
					out.flush();
				}
				
			}
		}.start();
		while(true){
			
			
			String echo = bin.readLine();
			System.out.println(echo);
			
			
		}
//		String line;
//		while ((line = bin.readLine()) != null) {
//			System.out.println(line);
//			out.println(line);
//			out.flush();
//		}
//		s.close();
//		out.close();
	}
}
